package com.tomehay.termprojectmanage_server.mapper;
import java.util.List;

import com.tomehay.termprojectmanage_server.pojo.VO.GroupMemberVO;
import org.apache.ibatis.annotations.Param;

import com.tomehay.termprojectmanage_server.pojo.Model.StudentGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tomehay
 * @since 2023-06-20
 */
public interface StudentGroupMapper extends BaseMapper<StudentGroup> {
    List<StudentGroup> selectAllById(@Param("id") Integer id);

    StudentGroup selectOneById(@Param("id") Integer id);
    @Select("SELECT group_member.*,student.name,student.student_no" +
            "        from group_member, student" +
            "        where group_member.group_id = #{group_id} AND group_member.student_id = student.id")
    List<GroupMemberVO> VOList(int group_id);

    @Select("SELECT distinct student_group.batch_id FROM student_group")
    int[] GetBatches();

    @Select("SELECT IFNULL(Max(student_group.group_no),-1) FROM student_group WHERE student_group.batch_id = #{batch_id} AND student_group.course_id = #{course_id} ")
    int findMaxGroupNo(int course_id,int batch_id);

    @Select("SELECT Max(student_group.batch_id) FROM student_group ")
    int findMaxBatch_id();
}
